﻿using HAOest.QrCodeForWin8.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// “空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=234238 上有介绍

namespace QrCodeForWin8
{
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class MainPage : Page
    {
        private QrCode qrCode = new QrCode();
        public MainPage()
        {
            this.InitializeComponent();
            CodeTypeComboBox.Items.Clear();
            CodeTypeComboBox.Items.Add(new CodeTypeComboBoxItem(CodeType.Text));
            CodeTypeComboBox.Items.Add(new CodeTypeComboBoxItem(CodeType.Tel));
            CodeTypeComboBox.DisplayMemberPath = "Text";
            CodeTypeComboBox.SelectedIndex = 0;
        }

        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。Parameter
        /// 属性通常用于配置页。</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {

        }

        private void InputTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            qrCode.Text = InputTextBox.Text;
            QrCodeControl.Text = qrCode.Text;
        }

        private void CodeTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            qrCode.CodeType = (CodeTypeComboBox.SelectedItem as CodeTypeComboBoxItem).CodeType;
        }
    }
}
